upgrade RSpec

Andrew Cantino 10 years ago
parent
commit
dfa71d1f45

+ 3 - 2
Gemfile

@@ -88,8 +88,9 @@ group :development, :test do
88 88
   gem 'vcr'
89 89
   gem 'dotenv-rails'
90 90
   gem 'pry'
91
-  gem 'rspec-rails', '~> 2.14'
92
-  gem 'rspec', '~> 2.14'
91
+  gem 'rspec-rails', '~> 2.99'
92
+  gem 'rspec', '~> 2.99'
93
+  gem 'rspec-collection_matchers'
93 94
   gem 'shoulda-matchers'
94 95
   gem 'rr'
95 96
   gem 'delorean'

+ 17 - 13
Gemfile.lock

@@ -238,22 +238,25 @@ GEM
238 238
       mime-types (>= 1.16)
239 239
     retriable (1.4.1)
240 240
     rr (1.1.2)
241
-    rspec (2.14.1)
242
-      rspec-core (~> 2.14.0)
243
-      rspec-expectations (~> 2.14.0)
244
-      rspec-mocks (~> 2.14.0)
245
-    rspec-core (2.14.8)
246
-    rspec-expectations (2.14.5)
241
+    rspec (2.99.0)
242
+      rspec-core (~> 2.99.0)
243
+      rspec-expectations (~> 2.99.0)
244
+      rspec-mocks (~> 2.99.0)
245
+    rspec-collection_matchers (1.0.0)
246
+      rspec-expectations (>= 2.99.0.beta1)
247
+    rspec-core (2.99.1)
248
+    rspec-expectations (2.99.2)
247 249
       diff-lcs (>= 1.1.3, < 2.0)
248
-    rspec-mocks (2.14.6)
249
-    rspec-rails (2.14.2)
250
+    rspec-mocks (2.99.2)
251
+    rspec-rails (2.99.0)
250 252
       actionpack (>= 3.0)
251 253
       activemodel (>= 3.0)
252 254
       activesupport (>= 3.0)
253 255
       railties (>= 3.0)
254
-      rspec-core (~> 2.14.0)
255
-      rspec-expectations (~> 2.14.0)
256
-      rspec-mocks (~> 2.14.0)
256
+      rspec-collection_matchers
257
+      rspec-core (~> 2.99.0)
258
+      rspec-expectations (~> 2.99.0)
259
+      rspec-mocks (~> 2.99.0)
257 260
     rturk (2.12.1)
258 261
       erector
259 262
       nokogiri
@@ -402,8 +405,9 @@ DEPENDENCIES
402 405
   rails (= 4.1.4)
403 406
   rails_12factor
404 407
   rr
405
-  rspec (~> 2.14)
406
-  rspec-rails (~> 2.14)
408
+  rspec (~> 2.99)
409
+  rspec-collection_matchers
410
+  rspec-rails (~> 2.99)
407 411
   rturk (~> 2.12.1)
408 412
   ruby-growl (~> 4.1.0)
409 413
   rufus-scheduler (~> 3.0.8)

+ 1 - 1
spec/controllers/agents_controller_spec.rb

@@ -14,7 +14,7 @@ describe AgentsController do
14 14
     it "only returns Agents for the current user" do
15 15
       sign_in users(:bob)
16 16
       get :index
17
-      assigns(:agents).all? {|i| i.user.should == users(:bob) }.should be_true
17
+      assigns(:agents).all? {|i| i.user.should == users(:bob) }.should be_truthy
18 18
     end
19 19
   end
20 20
 

+ 2 - 2
spec/controllers/events_controller_spec.rb

@@ -10,14 +10,14 @@ describe EventsController do
10 10
     it "only returns Events created by Agents of the current user" do
11 11
       sign_in users(:bob)
12 12
       get :index
13
-      assigns(:events).all? {|i| i.user.should == users(:bob) }.should be_true
13
+      assigns(:events).all? {|i| i.user.should == users(:bob) }.should be_truthy
14 14
     end
15 15
 
16 16
     it "can filter by Agent" do
17 17
       sign_in users(:bob)
18 18
       get :index, :agent_id => agents(:bob_website_agent)
19 19
       assigns(:events).length.should == agents(:bob_website_agent).events.length
20
-      assigns(:events).all? {|i| i.agent.should == agents(:bob_website_agent) }.should be_true
20
+      assigns(:events).all? {|i| i.agent.should == agents(:bob_website_agent) }.should be_truthy
21 21
 
22 22
       lambda {
23 23
         get :index, :agent_id => agents(:jane_website_agent)

+ 1 - 1
spec/controllers/logs_controller_spec.rb

@@ -6,7 +6,7 @@ describe LogsController do
6 6
       sign_in users(:bob)
7 7
       get :index, :agent_id => agents(:bob_weather_agent).id
8 8
       assigns(:logs).length.should == agents(:bob_weather_agent).logs.length
9
-      assigns(:logs).all? {|i| i.agent.should == agents(:bob_weather_agent) }.should be_true
9
+      assigns(:logs).all? {|i| i.agent.should == agents(:bob_weather_agent) }.should be_truthy
10 10
     end
11 11
 
12 12
     it "only loads Agents owned by the current user" do

+ 2 - 2
spec/controllers/scenarios_controller_spec.rb

@@ -12,7 +12,7 @@ describe ScenariosController do
12 12
   describe "GET index" do
13 13
     it "only returns Scenarios for the current user" do
14 14
       get :index
15
-      assigns(:scenarios).all? {|i| i.user.should == users(:bob) }.should be_true
15
+      assigns(:scenarios).all? {|i| i.user.should == users(:bob) }.should be_truthy
16 16
     end
17 17
   end
18 18
 
@@ -50,7 +50,7 @@ describe ScenariosController do
50 50
       assigns(:exporter).options[:description].should == scenarios(:bob_weather).description
51 51
       assigns(:exporter).options[:agents].should == scenarios(:bob_weather).agents
52 52
       assigns(:exporter).options[:guid].should == scenarios(:bob_weather).guid
53
-      assigns(:exporter).options[:source_url].should be_false
53
+      assigns(:exporter).options[:source_url].should be_falsey
54 54
       response.headers['Content-Disposition'].should == 'attachment; filename="bob-s-weather-alert-scenario.json"'
55 55
       response.headers['Content-Type'].should == 'application/json; charset=utf-8'
56 56
       JSON.parse(response.body)["name"].should == scenarios(:bob_weather).name

+ 1 - 1
spec/controllers/user_credentials_controller_spec.rb

@@ -15,7 +15,7 @@ describe UserCredentialsController do
15 15
   describe "GET index" do
16 16
     it "only returns UserCredentials for the current user" do
17 17
       get :index
18
-      assigns(:user_credentials).all? {|i| i.user.should == users(:bob) }.should be_true
18
+      assigns(:user_credentials).all? {|i| i.user.should == users(:bob) }.should be_truthy
19 19
     end
20 20
   end
21 21
 

+ 1 - 1
spec/helpers/dot_helper_spec.rb

@@ -89,7 +89,7 @@ describe DotHelper do
89 89
     end
90 90
   end
91 91
 
92
-  describe DotHelper::DotDrawer do
92
+  describe "DotHelper::DotDrawer" do
93 93
     describe "#id" do
94 94
       it "properly escapes double quotaion and backslash" do
95 95
         DotHelper::DotDrawer.draw(foo: "") {

+ 1 - 1
spec/lib/agents_exporter_spec.rb

@@ -20,7 +20,7 @@ describe AgentsExporter do
20 20
       Time.parse(data[:exported_at]).should be_within(2).of(Time.now.utc)
21 21
       data[:links].should == [{ :source => 0, :receiver => 1 }]
22 22
       data[:agents].should == agent_list.map { |agent| exporter.agent_as_json(agent) }
23
-      data[:agents].all? { |agent_json| agent_json[:guid].present? && agent_json[:type].present? && agent_json[:name].present? }.should be_true
23
+      data[:agents].all? { |agent_json| agent_json[:guid].present? && agent_json[:type].present? && agent_json[:name].present? }.should be_truthy
24 24
 
25 25
       data[:agents][0].should_not have_key(:propagate_immediately) # can't receive events
26 26
       data[:agents][1].should_not have_key(:schedule) # can't be scheduled

+ 1 - 1
spec/models/agent_spec.rb

@@ -213,7 +213,7 @@ describe Agent do
213 213
         @checker.last_check_at.should be_nil
214 214
         Agents::SomethingSource.async_check(@checker.id)
215 215
         @checker.reload.last_check_at.should be_within(2).of(Time.now)
216
-        @checker.reload.options[:new].should be_true # Show that we save options
216
+        @checker.reload.options[:new].should be_truthy # Show that we save options
217 217
       end
218 218
 
219 219
       it "should log exceptions" do

+ 2 - 2
spec/models/agents/growl_agent_spec.rb

@@ -60,7 +60,7 @@ describe Agents::GrowlAgent do
60 60
       end
61 61
       
62 62
       @checker.register_growl
63
-      called.should be_true
63
+      called.should be_truthy
64 64
     end
65 65
   end
66 66
   
@@ -78,7 +78,7 @@ describe Agents::GrowlAgent do
78 78
         mock(obj).notify(@checker.options[:growl_notification_name],subject,message)
79 79
       end
80 80
       @checker.notify_growl(subject,message)
81
-      called.should be_true
81
+      called.should be_truthy
82 82
     end
83 83
   end
84 84
   

+ 7 - 7
spec/models/agents/human_task_agent_spec.rb

@@ -323,7 +323,7 @@ describe Agents::HumanTaskAgent do
323 323
 
324 324
       @checker.send :review_hits
325 325
 
326
-      assignments.all? {|a| a.approved == true }.should be_false
326
+      assignments.all? {|a| a.approved == true }.should be_falsey
327 327
       @checker.memory['hits'].should == { "JH3132836336DHG" => { 'event_id' => @event.id } }
328 328
     end
329 329
 
@@ -341,7 +341,7 @@ describe Agents::HumanTaskAgent do
341 341
 
342 342
       @checker.send :review_hits
343 343
 
344
-      assignments.all? {|a| a.approved == true }.should be_false
344
+      assignments.all? {|a| a.approved == true }.should be_falsey
345 345
       @checker.memory['hits'].should == { "JH3132836336DHG" => { 'event_id' => @event.id } }
346 346
     end
347 347
 
@@ -360,7 +360,7 @@ describe Agents::HumanTaskAgent do
360 360
         @checker.send :review_hits
361 361
       }.should change { Event.count }.by(1)
362 362
 
363
-      assignments.all? {|a| a.approved == true }.should be_true
363
+      assignments.all? {|a| a.approved == true }.should be_truthy
364 364
       hit.should be_disposed
365 365
 
366 366
       @checker.events.last.payload['answers'].should == [
@@ -405,7 +405,7 @@ describe Agents::HumanTaskAgent do
405 405
           @checker.send :review_hits
406 406
         }.should change { Event.count }.by(1)
407 407
 
408
-        assignments.all? {|a| a.approved == true }.should be_true
408
+        assignments.all? {|a| a.approved == true }.should be_truthy
409 409
 
410 410
         @checker.events.last.payload['answers'].should == [
411 411
           { 'sentiment' => "sad", 'age_range' => "<50" },
@@ -458,7 +458,7 @@ describe Agents::HumanTaskAgent do
458 458
           @checker.send :review_hits
459 459
         }.should change { Event.count }.by(1)
460 460
 
461
-        assignments.all? {|a| a.approved == true }.should be_true
461
+        assignments.all? {|a| a.approved == true }.should be_truthy
462 462
 
463 463
         @checker.events.last.payload['answers'].should == [
464 464
           { 'rating' => "1" },
@@ -520,7 +520,7 @@ describe Agents::HumanTaskAgent do
520 520
 
521 521
         # it approves the existing assignments
522 522
 
523
-        assignments.all? {|a| a.approved == true }.should be_true
523
+        assignments.all? {|a| a.approved == true }.should be_truthy
524 524
         hit.should be_disposed
525 525
 
526 526
         # it creates a new HIT for the poll
@@ -582,7 +582,7 @@ describe Agents::HumanTaskAgent do
582 582
 
583 583
         # it approves the existing assignments
584 584
 
585
-        assignments.all? {|a| a.approved == true }.should be_true
585
+        assignments.all? {|a| a.approved == true }.should be_truthy
586 586
         hit.should be_disposed
587 587
 
588 588
         @checker.memory['hits'].should be_empty

+ 1 - 1
spec/models/agents/weibo_publish_agent_spec.rb

@@ -53,7 +53,7 @@ describe Agents::WeiboPublishAgent do
53 53
       Agents::WeiboPublishAgent.async_receive(@checker.id, [event.id])
54 54
       @sent_messages.count.should eq(1)
55 55
       @checker.events.count.should eq(1)
56
-      @sent_messages.first.include?("t.co").should_not be_true
56
+      @sent_messages.first.include?("t.co").should_not be_truthy
57 57
     end
58 58
   end
59 59
 

+ 8 - 8
spec/models/scenario_import_spec.rb

@@ -172,7 +172,7 @@ describe ScenarioImport do
172 172
           scenario_import.scenario.description.should == description
173 173
           scenario_import.scenario.guid.should == guid
174 174
           scenario_import.scenario.source_url.should == source_url
175
-          scenario_import.scenario.public.should be_false
175
+          scenario_import.scenario.public.should be_falsey
176 176
         end
177 177
 
178 178
         it "creates the Agents" do
@@ -186,7 +186,7 @@ describe ScenarioImport do
186 186
           weather_agent.name.should == "a weather agent"
187 187
           weather_agent.schedule.should == "5pm"
188 188
           weather_agent.keep_events_for.should == 14
189
-          weather_agent.propagate_immediately.should be_false
189
+          weather_agent.propagate_immediately.should be_falsey
190 190
           weather_agent.should be_disabled
191 191
           weather_agent.memory.should be_empty
192 192
           weather_agent.options.should == weather_agent_options
@@ -195,7 +195,7 @@ describe ScenarioImport do
195 195
           trigger_agent.sources.should == [weather_agent]
196 196
           trigger_agent.schedule.should be_nil
197 197
           trigger_agent.keep_events_for.should == 0
198
-          trigger_agent.propagate_immediately.should be_true
198
+          trigger_agent.propagate_immediately.should be_truthy
199 199
           trigger_agent.should_not be_disabled
200 200
           trigger_agent.memory.should be_empty
201 201
           trigger_agent.options.should == trigger_agent_options
@@ -272,7 +272,7 @@ describe ScenarioImport do
272 272
           existing_scenario.description.should == description
273 273
           existing_scenario.name.should == name
274 274
           existing_scenario.source_url.should == source_url
275
-          existing_scenario.public.should be_false
275
+          existing_scenario.public.should be_falsey
276 276
         end
277 277
 
278 278
         it "updates any existing agents in the scenario, and makes new ones as needed" do
@@ -290,7 +290,7 @@ describe ScenarioImport do
290 290
           weather_agent.name.should == "a weather agent"
291 291
           weather_agent.schedule.should == "5pm"
292 292
           weather_agent.keep_events_for.should == 14
293
-          weather_agent.propagate_immediately.should be_false
293
+          weather_agent.propagate_immediately.should be_falsey
294 294
           weather_agent.should be_disabled
295 295
           weather_agent.memory.should be_empty
296 296
           weather_agent.options.should == weather_agent_options
@@ -299,7 +299,7 @@ describe ScenarioImport do
299 299
           trigger_agent.sources.should == [weather_agent]
300 300
           trigger_agent.schedule.should be_nil
301 301
           trigger_agent.keep_events_for.should == 0
302
-          trigger_agent.propagate_immediately.should be_true
302
+          trigger_agent.propagate_immediately.should be_truthy
303 303
           trigger_agent.should_not be_disabled
304 304
           trigger_agent.memory.should be_empty
305 305
           trigger_agent.options.should == trigger_agent_options
@@ -318,7 +318,7 @@ describe ScenarioImport do
318 318
 
319 319
           scenario_import.should be_valid
320 320
 
321
-          scenario_import.import.should be_true
321
+          scenario_import.import.should be_truthy
322 322
 
323 323
           weather_agent = existing_scenario.agents.find_by(:guid => "a-weather-agent")
324 324
           weather_agent.name.should == "updated name"
@@ -338,7 +338,7 @@ describe ScenarioImport do
338 338
             }
339 339
           }
340 340
 
341
-          scenario_import.import.should be_false
341
+          scenario_import.import.should be_falsey
342 342
 
343 343
           errors = scenario_import.errors.full_messages.to_sentence
344 344
           errors.should =~ /Name can't be blank/

+ 5 - 0
spec/spec_helper.rb

@@ -32,6 +32,11 @@ RSpec.configure do |config|
32 32
   # instead of true.
33 33
   config.use_transactional_fixtures = true
34 34
 
35
+  # rspec-rails 3 will no longer automatically infer an example group's spec type
36
+  # from the file location. You can explicitly opt-in to this feature using this
37
+  # snippet:
38
+  config.infer_spec_type_from_file_location!
39
+
35 40
   # If true, the base class of anonymous controllers will be inferred
36 41
   # automatically. This will be the default behavior in future versions of
37 42
   # rspec-rails.

+ 5 - 5
spec/support/shared_examples/working_helpers.rb

@@ -7,23 +7,23 @@ shared_examples_for WorkingHelpers do
7 7
 
8 8
       agent.last_error_log_at = 10.minutes.ago
9 9
       agent.last_event_at = 10.minutes.ago
10
-      agent.recent_error_logs?.should be_true
10
+      agent.recent_error_logs?.should be_truthy
11 11
 
12 12
       agent.last_error_log_at = 11.minutes.ago
13 13
       agent.last_event_at = 10.minutes.ago
14
-      agent.recent_error_logs?.should be_true
14
+      agent.recent_error_logs?.should be_truthy
15 15
 
16 16
       agent.last_error_log_at = 5.minutes.ago
17 17
       agent.last_event_at = 10.minutes.ago
18
-      agent.recent_error_logs?.should be_true
18
+      agent.recent_error_logs?.should be_truthy
19 19
 
20 20
       agent.last_error_log_at = 15.minutes.ago
21 21
       agent.last_event_at = 10.minutes.ago
22
-      agent.recent_error_logs?.should be_false
22
+      agent.recent_error_logs?.should be_falsey
23 23
 
24 24
       agent.last_error_log_at = 2.days.ago
25 25
       agent.last_event_at = 10.minutes.ago
26
-      agent.recent_error_logs?.should be_false
26
+      agent.recent_error_logs?.should be_falsey
27 27
     end
28 28
   end
29 29